{include file="public/head" /}
<link rel="stylesheet" href="__STATIC__/datetimepicker/css/amazeui.datetimepicker.css"/>
<style>
    .am-panel {
        margin-top: 1%
    }

    .am-panel button {
        float: right
    }

    #Modal {
        height: 350px
    }
</style>
</head>
<body>
<header class="am-topbar am-topbar-inverse admin-header">
    <div class="am-topbar-brand">
        <strong><a href="/user/Index/index">网上选课系统</a></strong>
    </div>

    <button class="am-topbar-btn am-topbar-toggle am-btn am-btn-sm am-btn-success am-show-sm-only"
            data-am-collapse="{target: '#topbar-collapse'}"><span class="am-sr-only">导航切换</span> <span
            class="am-icon-bars"></span></button>

    <div class="am-collapse am-topbar-collapse" id="topbar-collapse">

        <ul class="am-nav am-nav-pills am-topbar-nav am-topbar-right admin-header-list">
            <li class="am-dropdown" data-am-dropdown>
                <a class="am-dropdown-toggle" data-am-dropdown-toggle href="javascript:;">
                    <span class="am-icon-user"></span> {$name} <span class="am-icon-caret-down"></span>
                </a>
                <ul class="am-dropdown-content">
                    <li><a href="javascript:;" onclick="openapp('/user/Index/changePassword')"><span class="am-icon-cog"></span> 修改密码</a></li>
                    <li><a href="javascript:;" id="loginOut"><span class="am-icon-power-off"></span> 注销</a></li>
                </ul>
            </li>
        </ul>
    </div>
</header>
<div class="am-cf admin-main">
    <div class="admin-sidebar am-offcanvas" id="admin-offcanvas">
        <div class="am-offcanvas-bar admin-offcanvas-bar">
            <ul class="am-list admin-sidebar-list">
                <li><a href="javascript:;" onclick="openapp('/user/Index/center')"><span class="am-icon-home"></span> 首页</a></li>
                {eq name="$type" value="1"}
                <li><a href="javascript:;" onclick="openapp('/user/Course/index')"><span class="am-icon-book"></span> 课程列表</a></li>
                <li><a href="javascript:;" onclick="openapp('/user/Course/myJoin')"><span class="am-icon-book"></span> 我的课程</a></li>
                {else\}
                <li><a href="javascript:;" onclick="openapp('/user/Course/myCreate')"><span class="am-icon-book"></span> 我开设的课程</a></li>
                <li><a href="javascript:;" onclick="openapp('/user/Course/create')"><span class="am-icon-plus"></span> 创建课程</a></li>
                {/eq}
                <li><a href="javascript:;" onclick="openapp('/user/Index/changePassword')"><span class="am-icon-cog"></span> 修改密码</a></li>
            </ul>
        </div>
    </div>
    <div class="admin-content">
        <iframe src="/user/Index/center" style="width:100%;height: 100%;overflow: auto" frameborder="no"
                scrolling="no" class="appiframe"></iframe>
    </div>
</div>
<script src="__STATIC__/datetimepicker/js/amazeui.datetimepicker.min.js"></script>
<script>
    $(function () {
        var userType = {$type};
        if (userType == 1) {
            $.get("/user/Index/checkSelectStatus", {}, function (res) {
                if (res.code == 0) {
                    $('#alert').modal();
                }
            }, "json");
        }
        //注销按钮监听点击事件
        $("#loginOut").on("click", function () {
            $.ajax({
                url: "/user/Login/loginOut",
                type: "get",
                success: function (res) {
                    console.log(res);
                    if (res.code == 1) {
                        layer.msg('注销成功', {time: 1000});
                        setTimeout(function () {
                            window.location.href = '/user/Login/index';
                        }, 1000);
                    }
                }
            });
        });
    });
    //切换iframe
    function openapp(url) {
        console.log(url);
        $("iframe").attr("src",url);
    }
</script>
</body>
</html>
